#region [file: AcessoDoUsuarioAoSistemaDAL.cs, author: Lucas Bittencourt]
// File:    AcessoDoUsuarioAoSistemaDAL.cs
// Author:  Lucas Bittencourt
// Created: terça-feira, 13 de setembro de 2011 23:34:04
// Purpose: Defines dao implementation class for class AcessoDoUsuarioAoSistema
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using NHibernate.Criterion;
using DA_OOMModel;
using DA_OOMModelIDAL;

namespace DA_OOMNHibernateDAL
{
   /// <summary>
   /// Class that implements methods of IAcessoDoUsuarioAoSistemaDAL interface
   /// </summary>
   public class AcessoDoUsuarioAoSistemaDAL : NHibernateDALBase,  IAcessoDoUsuarioAoSistemaDAL 
   {
      #region CRUD methods
      /// <summary>
      /// Get all instances of AcessoDoUsuarioAoSistema
      /// </summary>     
      public List<AcessoDoUsuarioAoSistema> GetAcessoDoUsuarioAoSistemaList()
      {
         return ConvertToGenericList(base.LoadAll(typeof(AcessoDoUsuarioAoSistema)));
      }
      
      /// <summary>
      /// Get the instances of AcessoDoUsuarioAoSistema from index firstResult to index maxResult
      /// </summary>
      public List<AcessoDoUsuarioAoSistema> GetAcessoDoUsuarioAoSistemaList(int firstResult, int maxResult)
      {
         return ConvertToGenericList(base.LoadAll(typeof(AcessoDoUsuarioAoSistema), firstResult, maxResult));
      }

      /// <summary>
      /// Load the instance of AcessoDoUsuarioAoSistema according its primary key instance.
      /// </summary>
      public AcessoDoUsuarioAoSistema Load(AcessoDoUsuarioAoSistemaPK acessoDoUsuarioAoSistemaPK)
      {
         IList cs = new ArrayList();
         string[] paramNames = new string[] { "AcuIdAcessoUsuario" };
         object[] values = new object[] { acessoDoUsuarioAoSistemaPK.AcuIdAcessoUsuario };
         for (int i = 0; i < paramNames.Length; i++)
             cs.Add(Expression.Eq(paramNames[i], values[i]));

         IList list = base.FindByCriterions(typeof(AcessoDoUsuarioAoSistema), cs);
         return (((list != null) && (list.Count > 0)) ? (AcessoDoUsuarioAoSistema)list[0] : null);
      }

      /// <summary>
      /// Query the instances of AcessoDoUsuarioAoSistema according its example instance.
      /// </summary>
      public List<AcessoDoUsuarioAoSistema> QueryByExample(AcessoDoUsuarioAoSistema acessoDoUsuarioAoSistema)
      {
         return ConvertToGenericList(base.QueryByExample(typeof(AcessoDoUsuarioAoSistema), acessoDoUsuarioAoSistema));
      }

      /// <summary>
      /// Query the instances of AcessoDoUsuarioAoSistema according its example instance from index firstResult to index maxResult
      /// </summary>
      public List<AcessoDoUsuarioAoSistema> QueryByExample(AcessoDoUsuarioAoSistema acessoDoUsuarioAoSistema, int firstResult, int maxResult)
      {
         return ConvertToGenericList(base.QueryByExample(typeof(AcessoDoUsuarioAoSistema), acessoDoUsuarioAoSistema, firstResult, maxResult));
      }
      
      /// <summary>
      /// Insert the instances of AcessoDoUsuarioAoSistema
      /// </summary>
      public void Insert(AcessoDoUsuarioAoSistema acessoDoUsuarioAoSistemaObject)
      {
         base.Save(acessoDoUsuarioAoSistemaObject);
      }
      
      /// <summary>
      /// Update the instances of AcessoDoUsuarioAoSistema
      /// </summary>
      public void Update(AcessoDoUsuarioAoSistema acessoDoUsuarioAoSistemaObject)
      {
         base.Update(acessoDoUsuarioAoSistemaObject);
      }
      
      /// <summary>
      /// Delete the instances of AcessoDoUsuarioAoSistema
      /// </summary>
      public void Delete(AcessoDoUsuarioAoSistema acessoDoUsuarioAoSistemaObject)
      {
         base.Delete(acessoDoUsuarioAoSistemaObject);
      }
      #endregion
      
   
      /// <summary>
      /// Find the instances of AcessoDoUsuarioAoSistema according to its attribute acuDtAcesso
      /// </summary>
      public List<AcessoDoUsuarioAoSistema> FindByAcuDtAcesso(DateTime acuDtAcesso) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("AcuDtAcesso", acuDtAcesso));
         return ConvertToGenericList(base.FindByCriterions(typeof(AcessoDoUsuarioAoSistema), cs));
      }
      
      /// <summary>
      /// Find the instances of AcessoDoUsuarioAoSistema according to its attribute acuDtAcesso, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<AcessoDoUsuarioAoSistema> FindByAcuDtAcesso(DateTime acuDtAcesso, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("AcuDtAcesso", acuDtAcesso));
         return ConvertToGenericList(base.FindByCriterions(typeof(AcessoDoUsuarioAoSistema), cs, firstResult, maxResult));
      }
      
      /// <summary>
      /// Find <Code>AcessoDoUsuarioAoSistema</Code> instances by Usuario
      /// </summary>
      /// <param name="usuario"/>
      /// <returns>AcessoDoUsuarioAoSistema instance list</returns>
      public List<AcessoDoUsuarioAoSistema> FindByUsuario(Usuario usuario)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Usuario", usuario));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs));
      }
      
      /// <summary>
      /// Find <Code>AcessoDoUsuarioAoSistema</Code> instances  instances in range firstResult, maxResult by Usuario
      /// </summary>
      /// <param name="usuario"/>
      /// <param name="firstResult">first result to return</param>
      /// <param name="maxResult">max result to return</param>
      /// <returns>AcessoDoUsuarioAoSistema instance list</returns>
      public List<AcessoDoUsuarioAoSistema> FindByUsuario(Usuario usuario, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Usuario", usuario));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs, firstResult, maxResult));
      }

      /// <summary>
      /// Convert the IList to the generic List instance.
      /// </summary>
      private List<AcessoDoUsuarioAoSistema> ConvertToGenericList(IList acessoDoUsuarioAoSistemas)
      {
         List<AcessoDoUsuarioAoSistema> acessoDoUsuarioAoSistemaList = new List<AcessoDoUsuarioAoSistema>();
         foreach (AcessoDoUsuarioAoSistema acessoDoUsuarioAoSistema in acessoDoUsuarioAoSistemas)
         {
             acessoDoUsuarioAoSistemaList.Add(acessoDoUsuarioAoSistema);
         }
         return acessoDoUsuarioAoSistemaList;
      }      
   }
}